package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-15
 * Time: 21:28
 */
public /*final(这个类不想被别的类继承就用final修饰)*/ class Animal {
    public String name;
    public int age;
    int a = 1;
    public void eat(){

        System.out.println(this.name + "正在吃东西");
    }
    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("构造方法--Animal");
    }
    static {
        System.out.println("static--Animal");
    }
    {
        System.out.println("实例代码块--Animal");
    }
}
